﻿Public Class Relance_Screen

    Private _ctrl As Relance_CTRL

    Public Sub New(ByVal ctrl As Relance_CTRL)

        ' Cet appel est requis par le Concepteur Windows Form.
        InitializeComponent()

        ' Ajoutez une initialisation quelconque après l'appel InitializeComponent().
        _ctrl = ctrl

    End Sub

    Private Sub RafraichirDGVRelance()
        DGVrelance.DataSource = Nothing
        DGVrelance.DataSource = _ctrl.getListeRelancable
    End Sub

    Private Sub Relance_Screen_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        RafraichirDGVRelance()
    End Sub

    Private Sub BTNrelancer_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BTNrelancerSelection.Click, BTNrelancerTOUT.Click
        If sender.Equals(BTNrelancerTOUT) Then
            For Each row As DataGridViewRow In DGVrelance.Rows
                CType(row.DataBoundItem, LignesConsultations).RappelEnvoye = True
            Next
        End If
        For Each row As DataGridViewRow In DGVrelance.Rows
            Dim ligne As New LignesConsultations
            ligne = CType(row.DataBoundItem, LignesConsultations)
            If ligne.RappelEnvoye = True Then
                _ctrl.AjouterDansListeARelancer(ligne)
            End If
        Next

        Dim frm As New DialogueRelance
        With frm
            Dim DataSource As Microsoft.Reporting.WinForms.ReportDataSource = New Microsoft.Reporting.WinForms.ReportDataSource()
            DataSource.Name = "AniForm_Modele_LignesConsultations"
            DataSource.Value = _ctrl.getListeARelancer
            .ReportViewer.LocalReport.DataSources.Clear()
            .ReportViewer.LocalReport.DataSources.Add(DataSource)
            .ShowDialog(Me)
            .Dispose()
        End With

        RafraichirDGVRelance()
    End Sub
End Class